package com.bridgeintelligent.tag.webserver.dim.mgmt.service.operation;

import com.bridgeintelligent.tag.webserver.workflow.ApproverService;
import com.bridgeintelligent.tag.webserver.workflow.History;
import com.bridgeintelligent.tag.webserver.workflow.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "变更记录")
@AllArgsConstructor
@RestController
@RequestMapping("/api/workflow")
@Slf4j
public class OperationRecordController {

    private ApproverService approverService;

    /**
     * 获取某个资源的变更记录
     *
     * @return
     */
    @ApiOperation("获取某个资源的变更记录")
    @ApiImplicitParams({@ApiImplicitParam(paramType = "query", name = "resourceId", value = "resourceId")
    })
    @GetMapping("/OperationList")
    public Result OperationList(String resourceId) {
        List<History> list = approverService.findOperationRecord(resourceId);
        return new Result(0, list);
    }

}